package com.mb;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import com.facade.MedicalFacade;
import com.model.Medical;

@ViewScoped
@ManagedBean
public class MedicalMB extends AbstractMB implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private Medical medical;
	private List<Medical> medicals; 
	private MedicalFacade medicalFacade; 
	
	public List<Medical> getAllMedicals() {
		if (medicals == null) {
			loadMedicals();
		}

		return medicals;
	}

	private void loadMedicals() {
		medicals = getMedicalFacade().listAll();
	}

	public Medical getMedical() {
		if(medical == null){
			medical = new Medical();
		}
		return medical;
	}

	public void setMedical(Medical medical) {
		this.medical = medical;
	}

	public List<Medical> getMedicals() {
		if(medicals == null){
			medicals = getAllMedicals();
		}
		return medicals;
	}

	public void setMedicals(List<Medical> medicals) {
		this.medicals = medicals;
	}

	public MedicalFacade getMedicalFacade() {
		if(medicalFacade == null){
			medicalFacade = new MedicalFacade();
		}
		return medicalFacade;
	}

	public void setMedicalFacade(MedicalFacade medicalFacade) {
		this.medicalFacade = medicalFacade;
	}
	

}
